package com.pervasive.geoTagging;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.RectF;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class LocationOverlay extends Overlay{

	public LocationOverlay(GeoPoint you) {
		position = you;
	}
	
	public void draw(Canvas canvas, MapView map, boolean shadow){
		Projection projection = map.getProjection();
		if(!shadow){
			Point point = new Point();
			projection.toPixels(position, point);
			int raggio = 5;
			Paint paint = new Paint();
			paint.setColor(Color.BLACK);
			paint.setFakeBoldText(true);
			paint.setAntiAlias(true);
			RectF oval = new RectF(point.x-raggio, point.y-raggio, point.x+raggio, point.y+raggio);
			canvas.drawOval(oval, paint);
			canvas.drawText(map.getResources().getString(R.string.geolocalizzazione), point.x+2*raggio, point.y, paint);
		}
		super.draw(canvas, map, shadow);
	}
	
	public double getLatitude(){
		return ((double)position.getLatitudeE6())/1E6;
	}
	
	public double getLongitude(){
		return ((double)position.getLongitudeE6())/1E6;
	}
	
	private GeoPoint position;
}

